package gui;

import org.eclipse.swt.*;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;


public class SWTCodegGUITester {
    public static void test(SWTCodegGUI codeg) {
        final Display display = new Display();
        final Shell shell = new Shell(display);

        shell.setLayout(new FillLayout());
        ScrolledComposite scroll = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
        Composite content = new Composite(scroll, SWT.NONE);
        scroll.setContent(content);
        scroll.setExpandHorizontal(true);
        scroll.setExpandVertical(true);
        
        content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        codeg.populate(content);
        shell.pack();
        scroll.setMinSize(content.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) display.sleep();
        }
        display.dispose();
    }
}